package com.zkt.subject.infra.basic.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.zkt.subject.infra.basic.entity.SubjectCategory;
import com.zkt.subject.infra.basic.mapper.SubjectCategoryMapper;
import com.zkt.subject.infra.basic.service.ISubjectCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 题目分类 服务实现类
 * </p>
 *
 * @author zkt
 * @since 2024-09-27
 */
@Service
public class SubjectCategoryServiceImpl extends ServiceImpl<SubjectCategoryMapper, SubjectCategory> implements ISubjectCategoryService {
	
	/**
	 * 查询题目分类
	 *
	 * @param subjectCategory 查询条件
	 * @return 题目分类列表
	 */
	@Override
	public List<SubjectCategory> queryCategory(SubjectCategory subjectCategory) {
		return this.lambdaQuery()
				.eq(ObjectUtil.isNotNull(subjectCategory.getId()),
						SubjectCategory::getId, subjectCategory.getId())
				.like(StrUtil.isNotBlank(subjectCategory.getCategoryName()), SubjectCategory::getCategoryName,
						subjectCategory.getCategoryName())
				.eq(ObjectUtil.isNotNull(subjectCategory.getCategoryType()), SubjectCategory::getCategoryType,
						subjectCategory.getCategoryType())
				.eq(ObjectUtil.isNotNull(subjectCategory.getParentId()), SubjectCategory::getParentId,
						subjectCategory.getParentId())
				.like(StrUtil.isNotBlank(subjectCategory.getCreatedBy()), SubjectCategory::getCreatedBy,
						subjectCategory.getCreatedBy())
				.like(StrUtil.isNotBlank(subjectCategory.getUpdateBy()), SubjectCategory::getUpdateBy,
						subjectCategory.getUpdateBy())
				.eq(ObjectUtil.isNotNull(subjectCategory.getCreatedTime()), SubjectCategory::getCreatedTime,
						subjectCategory.getCreatedTime())
				.eq(ObjectUtil.isNotNull(subjectCategory.getUpdateTime()), SubjectCategory::getUpdateTime,
						subjectCategory.getUpdateTime())
				.list();
	}
}
